package com.insurance.common.utils;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * 分页公共请求参数
 */
public class QueryList<T> implements Serializable {
    private int page = 1;
    private int pageSize = 10;

    @Valid
    @NotNull(message = "参数不能为空")
    private T params;

    /**
     * 开始的记录数
     *
     * @return
     */
    public int getStartNum() {
        return (page - 1) * pageSize;
    }

    /**
     * 结束的记录数
     *
     * @return
     */
    public int getEndNum() {
        // 页数＊每页行数
        return this.getStartNum() +  pageSize;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public T getParams() {
        return params;
    }

    public void setParams(T param) {
        this.params = param;
    }

}
